const state = {
  school: new Array(),
  schoolSelectModel: ''
}
const mutations = {
  SET_SCHOOL: (state, data) => {
    try {
      for (let i = 0; i < state.school.length; i++) {
        if (state.school[i].id == data.id) {
            state.school.splice(i, 1)
        }
      }
    } catch (e) {
    }
      state.school.push(data)
  },
  SET_SCHOOL_SELECT_MODEL: (state, data) => {
      state.schoolSelectModel=data
  },
  CLEAN_SCHOOL: (state) => {
    state.school = new Array()
    state.schoolSelectModel=''
  },
  CLEAN_SCHOOL_DATA: (state) => {
    state.school = new Array()
  }
}

const actions = {
  // 设置代理等级
  setSchool({ commit }, data) {
    commit('SET_SCHOOL', data)
  },
  // 设置代理选择模式
  setSchoolSelectModel({ commit }, data) {
    commit('SET_SCHOOL_SELECT_MODEL', data)
  },
  // 清空代理-全部清空
  cleanSchool({ commit }) {
    commit('CLEAN_SCHOOL')
  },
  // 清空代理-选中数据
  cleanSchoolData({ commit }) {
    commit('CLEAN_SCHOOL_DATA')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

